A General Backtrack Algorithm That Eliminates Most Redundant Tests

نویسنده

  • John Gaschnig
چکیده

We def ine a faster algorithm functionally equivalent to the classical backtrack algorithm for assignment p rob lems , of wh ich the Eight Queens puzzle is an e l emen ta r y example (Fi l lmore & Williamson 1974, Knuth 1975 ] . Exper imental measurements (f igure 1) reveal r educ t i on by a factor of 2.5 for the 8-queens puzzle ( fac to r of 8.7 for 16 queens) in T, the number of pairtests p e r f o r m e d be fo re f inding a solution (i.e., f irst solution). A p a i r t e s t in this case determines whether a queen on square ( i j , j j ) attacks a queen on square (12, j2^ i C P U " seconds, net speedup is by a factor of 2.0 and 6.0 for 8and 16-queens , respect ive ly . 16-queens was solved in 0.14 seconds on a PDP KL/10. The speedup can be at t r ibuted to the e l iminat ion of almost all redundant tests otherwise r e c o m p u t e d in many parts of the search tree, as indicated in f i gu re 2, wh ich shows the mean number of times, D, an a r b i t r a r y pa i r t es t is executed. If D = 1 then all tests are d is t inc t (no recomputatiOn). Note that each data point in the f i gu res represen ts the mean over 30 or 70 problem instances that d i f fer as fol lows: instead of instantiating queen 3, say, on square (3,1), then on (3,2),..., then (3,8), these 8 squares are o rdered randomly. A problem instance is de f i ned by choosing a "legal squares order ing" for each queen . Random order ing general ly gives a smaller value of T, on the average, than the "natura l " 1,2,3,...,N ordering (for 2 0 q u e e n s , a factor of 5 00 smaller!). The a lgor i thm exploi ts an advantageous time-space t radeo f f and is def ined below in general form by recursive SAIL p rocedu re BKMARK [Swinehart & Sproull 1971]. The classical backt rack algori thm is defined the same, minus the unde r l i ned por t ions (except that "NEW[VAR]" in line 7 is rep laced by "1") . The algorithm applies to any problem hav ing NVARS var iables (8, for 8-queens), each variable Xj hav ing NVALSH] a p r io r i possible values (8 squares for each queen (one row of board), except 4 for queen 1 for s y m m e t r y reasons). An assignment vector ASSIGN[1:NVARS] of values to variables is a solution iff PAIRTEST0, ASSIGN[i] , j , ASSIGN[j]) is true for all 0 < i < j < NVARS (iff no queen can take any other queen). Be low, ASSIGN contains indices to the actual values. Top leve l invocat ion for 8-queens takes the form tmp <BKMARKO, 8, A, B, C, D) wi th array dimensions D[1:NVARS] and C[1:NVARS, l :k ] , where k is the maximum of the B [ i ] values (-8 for 8-queens). Initial values of A are i r r e l evan t ; C and D values are initially 1. BKMARK returns 1, w i t h solut ion in ASSIGN, or returns 0 if no solution ex is ts . Define PAIRTEST for 8-queens and trace the execu t ion (new vs. old versions) to see how it works. (Suggest ion : def ine an array VALUES wi th same dimensions as MARK, so that an element of VALUES encodes a board locat ion.) For b rev i t y , the symbol st.ands for "comment".

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Interval Analysis of Controllable Workspace for Cable Robots

Workspace analysis is one of the most important issues in the robotic parallel manipulator design. ‎However, ‎the unidirectional constraint imposed by cables causes this analysis more challenging in the cabledriven redundant parallel manipulators. Controllable workspace is one of the general workspace in the cabledriven redundant parallel manipulators due to the dependency on geometry parameter...

متن کامل

ce-Bounded Learning Algorith Constraint Satisfaction Problem

Learning during backtrack search is a space-intensive process that records information (such as additional constraints) in order to avoid redundant work. In this paper, we analyze the effects of polynomial-spacebounded learning on runtime complexity of backtrack search. One space-bounded learning scheme records only those constraints with limited size, and another records arbitrarily large cons...

متن کامل

Partial Evaluation applied to Symbolic Pattern Matching with Intelligent Backtrack

Partial version presented at Workshop for Static Analysis (Bor-deaux France) october 1992. Abstract Symbolic pattern matching as ooered by Lisp dialects allows to scan Sexpressions, to verify their shape and to extract or compare subparts of them. A rich set of patterns exists and among them alternate patterns. Such patterns are handled through backtrack: a failure forces the pattern matcher to...

متن کامل

A Complexity Analysis of Space-Bounded Learning Algorithms for the Constraint Satisfaction Problem

Learning during backtrack search is a space-intensive process that records information (such as additional constraints) in order to avoid redundant work. In this paper, we analyze the effects of polynomial-spacebounded learning on runtime complexity of backtrack search. One space-bounded learning scheme records only those constraints with limited size, and another records arbitrarily large cons...

متن کامل

Nogood Recording for Valued Constraint Satisfaction Problems

In the frame of classical Constraint Satisfaction Problems (CSPs), the backtrack tree search, combined with learning methods, presents a double advantage : for static solving, it improves the search speed by avoiding redundant explorations; for dynamic solving (after a slight change of the problem), it reuses the previous searches to build a new solution quickly. Backtrack reasoning concludes t...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1977